package com.activenetwork.smlite.testcase.events.createEvents.basics;

import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;

import com.activenetwork.smlite.page.event.EventDetailView.EventBasicSubview;
import com.activenetwork.smlite.snippet.EventsSnippet;
import com.activenetwork.smlite.testcase.BaseCase;
import com.activenetwork.util.EnvContext;
import com.activenetwork.util.verification.gson.FailureAssertion;
import com.activenetwork.util.verification.gson.FailurePoint;

public class Basics002 extends BaseCase {
	static final Logger logger = LoggerFactory.getLogger(Basics002.class);
	
	@Test
	public void Verify_Basic_Message_can_show_or_hide_on_Event_Basic_page(){
		loginBusiness.login();
		
		EventBasicSubview eventBasicSubview = EventsSnippet.gotoAddEventPage();
		
		logger.info("Verify the Basic can hide/show");
		try{
			WebElement helpDiv = webDriver.findElement(By.cssSelector(".autotest-html-eventbasicsubview #nexus-basic-help"));
			String value = helpDiv.getAttribute("class").trim();
			if(StringUtils.equalsIgnoreCase(value, "collapse")){ //hide
				eventBasicSubview = eventBasicSubview.showBasicMsg();
				eventBasicSubview = eventBasicSubview.hideBasicMsg();
			}else{
				eventBasicSubview = eventBasicSubview.hideBasicMsg();
				eventBasicSubview = eventBasicSubview.showBasicMsg();
			}
		}catch(Exception e){
			EnvContext.failurePointTL.get().add(
					new FailurePoint(Basics002.class.getName(), "VerifyShowHideBasicMessage", "Unable to show/hide the basic message"));
		}
		
		// logout
		loginBusiness.logout();
		
		// Popup failures
		FailureAssertion.pop(Basics002.class);
	}

}
